package pt.isel.lercm.projectmanager.spring.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pt.isel.lercm.projectmanager.spring.dao.AlunoDAO;
import pt.isel.lercm.projectmanager.spring.model.Aluno;


@Service("AlunoService")
@Transactional(readOnly = true)
public class AlunoService implements IAlunoService{

	@Autowired
	AlunoDAO alunoDao;

	public AlunoDAO getAlunoDao() {
		return alunoDao;
	}

	public void setAlunoDao(AlunoDAO alunoDao) {
		this.alunoDao = alunoDao;
	}
	
	@Transactional(readOnly = false)
	@Override
	public void add(Aluno aluno){
		getAlunoDao().addObject(aluno);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void update(Aluno aluno){
		getAlunoDao().updateObject(aluno);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void delete(Aluno aluno){
		getAlunoDao().deleteObject(aluno);
	}
	
	@Override
	public Aluno getById(int id){
		return getAlunoDao().getByid(id);
	}
	
	@Override
	public List<Aluno> getAll(){
		return getAlunoDao().getAll();
	}
	
	public Aluno getAlunoByNumero(String numero){
		return getAlunoDao().getAlunoByNumero(numero);
	}

	@Override
	public List<Aluno> getAllByYear(int idAno) {
		return getAlunoDao().getAllByYear(idAno);
	}
}
